import 'package:flutter/material.dart';

class Home extends StatefulWidget {
  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
  int _currentIndex = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      bottomNavigationBar: BottomNavigationBar(
        unselectedItemColor: Colors.black45,
        iconSize: 30,
        type: BottomNavigationBarType.fixed,
        unselectedFontSize: 14,
        selectedFontSize: 16,
        showSelectedLabels: true,
        showUnselectedLabels: true,
        selectedItemColor: Colors.red,
        currentIndex: _currentIndex,
        onTap: (index) {
          setState(() {
            _currentIndex = index;
          });
        },
        items: const [
          BottomNavigationBarItem(
            icon: Icon(Icons.home_filled),
            label: "首页",
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.shop),
            label: "逛",
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.ac_unit),
            label: "新品",
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.shopping_cart_outlined),
            label: "购物车",
          ),
          BottomNavigationBarItem(
            icon: Icon(Icons.account_circle_outlined),
            label: "我的",
          ),
        ],
      ),
     // body: SafeArea(child: Body(),),
      body: Body(),
    );
  }
}

class Body extends StatefulWidget {
  @override
  _BodyState createState() => _BodyState();
}

class _BodyState extends State<Body> {
  @override
  Widget build(BuildContext context) {
    //头部
    return Container(
      height: 160,
      //渐变色
      decoration: BoxDecoration(
          gradient: LinearGradient(
              colors: [Color.fromARGB(255, 246, 172, 172), Color.fromARGB(
                  255, 245, 202, 202)])),
      child: Column(
      children: [
        //搜索框上部
        Container(
          margin: const EdgeInsets.fromLTRB(0,25,0,0),
          child: Row(
            children: [
              Expanded(
                  child: Container(
                    alignment: Alignment.center,
                    height: 40,
                    width: 100,
                    child: Image.asset(
                      "images/gif/qinqin.gif",
                      width: 100,
                    ),
                  )),
              Expanded(
                  child: Container(
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(10),
                        color: Color.fromARGB(255, 250, 169, 231),
                      ))),
              Expanded(
                  child: Container(
                    width: 50,
                    height: 40,
                    padding: const EdgeInsets.fromLTRB(10, 0, 20, 0),
                    child: Row(
                      textDirection: TextDirection.rtl,
                      children: [
                        Image.asset("images/liuyan.jpeg"),
                        Image.asset("images/gif/hongbao.gif")
                      ],
                    ),
                  ))
            ],
          ),
        ),
        //搜索框
        Container(
          margin: const EdgeInsets.fromLTRB(0,10,0,0),
          height: 40,
          width: 350,
          decoration: BoxDecoration(borderRadius: BorderRadius.circular(50),
            color: Colors.white,
          ),
          child: Row(children: [
            Container(
              width: 50,
              padding:const EdgeInsets.fromLTRB(10,5,10,0),
              child: Icon(Icons.search,size: 30,color: Colors.red,),),
            Container(
              padding: const EdgeInsets.fromLTRB(10,0,10,0),
              width: 300,
              child:  Row(
              textDirection:TextDirection.rtl,
              children: [
                Container(
                  padding: const EdgeInsets.fromLTRB(5,0,0,0),
                  child: const Icon(Icons.zoom_out_map_sharp,size: 30,color: Colors.black45,),),
              const SizedBox(
                width: 1,
                height: 20,
                child: DecoratedBox(
                  decoration: BoxDecoration(color: Colors.grey),
                ),
              ),
                Container(
                  padding: const EdgeInsets.fromLTRB(0,0,5,0),
                  child: const Icon(Icons.camera_alt_outlined,size: 30,color: Colors.black45,),),
              ],),)
          ],),)
      ],
    ),);
  }
}
